str1="abcdefge";
print("ab=\n");
fp = fopen("testfile1.txt", "w");
fputs("abcdefg\n", fp);
fputs("hijklmn\n", fp);
fclose(fp);


stationIdToLocationFun(102);
#stationIdToLocationFun(33);
#stationIdToLocationFun(103);
#stationIdToLocationFun(105);

function stationIdToLocationFun(stationId1)
{
    locationId1 = stationIdToLocation(stationId1);
    if (locationId1 < 0)
    {
        print("[" + stationId1 + "]->[" + locationId1+ "]\n");
        return;
    }

    zoneId = locationId1 / 1000000;
    queueId = (locationId1 % 1000000) / 1000;
    gridId = locationId1 % 1000;
    print("[" + stationId1 + "]->[" + "" + locationId1
        + "]["+zoneId + "-" + queueId + "-" + gridId
        + "]\n");
}

function stationIdToLocation(stationId1)
{
    zoneId = 1;
    queueId = 1;
    gridId = 1;
    if ( (1 == stationId1) || (2 == stationId1) )
    {
        print("<10");
        zoneId = 0;
        queueId = stationId1 - 1;
        gridId = 0;
    }
    elsif (stationId1 <= 100)
    {
        print("<100");
        return -1;
    }
    elsif ( stationId1 < 200 )
    {
        print("<200");
        zoneId = 1;
        temp = stationId1 - 100;
        queueId = temp- 1;
        gridId = 0;
    }
    elsif (stationId1 < 300)
    {
        print("<300");
        zoneId = 2;
        temp = stationId1 - 200;
        queueId = temp - 1;
        gridId = 0;
    }
    elsif (stationId1 < 400)
    {
        print("<400\n");
        zoneId = 3;
        temp = stationId1 - 300;
        queueId = temp - 1;
        gridId = 0;
    }
    else
    {
        return -1;
    }
    print("zoneId=" + zoneId + "," + queueId + ","+ gridId + "\n");
    return zoneId * 1000000 + queueId * 1000 + gridId;
}


